package com.sh.rabbitmq;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.sh.rabbitmq.utils.ChannelFactory;

import java.util.Scanner;

public class Producer {

    //普通交换机
    public static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel = ChannelFactory.getChannel();

        //消息过期时间
        //AMQP.BasicProperties bc = new AMQP.BasicProperties().builder().expiration("10000").build();


        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String next = sc.next();
            channel.basicPublish(NORMAL_EXCHANGE, "zhangsan", null, next.getBytes("utf-8"));
            System.out.println("发送成功");
        }

    }
}
